package hy.day3_02;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/login")
public class Login extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String user = req.getParameter("user");
        String pass=req.getParameter("pass");
        System.out.println("user:"+user+",pass:"+pass);
        //转发有效
        req.setAttribute("u" , user);
        //通过session传值
        HttpSession session =req.getSession();
        session.setAttribute("u", user);
        req.getRequestDispatcher("/info/dis").forward(req,resp);
//        resp.sendRedirect("/day3_02/info/abc");
    }
}